<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    '<div contenteditable><div>f^oo</div>bar|<br></div>',
    'insertHTML <div>foo</div><br class="Apple-interchange-newline">',
    '<div contenteditable><div>ffoo</div><div>|<br></div></div>'),
    'BR interchange-newline is not inserted');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div style="color:red">b^ar</div>',
            '<div style="color:blue">baz|<br></div>',
        '</div>',
    ].join(''),
    'insertHTML <div>FOO</div><div>BAR</div>',
    [
        '<div contenteditable>',
            '<div style="color:red">bFOO</div>',
            // last BR isn't copied from original DIV.
            '<div>BAR|</div>',
        '</div>',
    ].join('')),
    'Use existing DIV for partial replacement');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div style="color:red">b^ar</div>',
            'baz|<br>',
        '</div>',
    ].join(''),
    'insertHTML <div>FOO</div><div>BAR</div>',
    [
        '<div contenteditable>',
            '<div style="color:red">bFOO</div>',
            '<div>BAR|</div>',
        '</div>',
    ].join('')),
    'Replace text+BR to DIV');
</script>
